package org.jeecg.modules.demo.manage.service.impl;

import org.jeecg.modules.demo.manage.entity.DzMaterialSpu;
import org.jeecg.modules.demo.manage.entity.DzMaterialSku;
import org.jeecg.modules.demo.manage.mapper.DzMaterialSkuMapper;
import org.jeecg.modules.demo.manage.mapper.DzMaterialSpuMapper;
import org.jeecg.modules.demo.manage.service.IDzMaterialSpuService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.util.List;
import java.util.Collection;

/**
 * @Description: 物料管理
 * @Author: jeecg-boot
 * @Date:   2024-11-24
 * @Version: V1.0
 */
@Service
public class DzMaterialSpuServiceImpl extends ServiceImpl<DzMaterialSpuMapper, DzMaterialSpu> implements IDzMaterialSpuService {

	@Autowired
	private DzMaterialSpuMapper dzMaterialSpuMapper;
	@Autowired
	private DzMaterialSkuMapper dzMaterialSkuMapper;
	
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delMain(String id) {
		dzMaterialSkuMapper.deleteByMainId(id);
		dzMaterialSpuMapper.deleteById(id);
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delBatchMain(Collection<? extends Serializable> idList) {
		for(Serializable id:idList) {
			dzMaterialSkuMapper.deleteByMainId(id.toString());
			dzMaterialSpuMapper.deleteById(id);
		}
	}
	
}
